import java.util.Scanner;

/**
 * Created by hansheng11 on 2019/12/3 17:09.
 */
public class 第8题_字符串转换整数atoi {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        while (sc.hasNext()) {
            String str = sc.next();
            System.out.println(myAtoi(str));
        }
    }

    public static int myAtoi(String str) {
        if (str == null) {
            return 0;
        }
        int i = 0;
        while (i < str.length() && str.charAt(i) == ' ') {
            i++;
        }
        str = str.substring(i);
        if ("".equals(str)) {
            return 0;
        }
        long temp = 0;
        boolean tag = false;
        if (str.charAt(0) == '-') {
            tag = true;
        } else if (str.charAt(0) == '+') {
            tag = false;
        } else if (str.charAt(0) >= '0' && str.charAt(0) <= '9') {
            temp = Long.parseLong(String.valueOf(str.charAt(0)));
        } else {
            return 0;
        }
        for (int j = 1; j < str.length(); j++) {
            if (str.charAt(j) >= '0' && str.charAt(j) <= '9') {
                temp = temp * 10 + Long.parseLong(String.valueOf(str.charAt(j)));
            } else {
                break;
            }
            if (str.charAt(0) == '-' && (-temp) <= Integer.MIN_VALUE) {
                return Integer.MIN_VALUE;
            }
            if (str.charAt(0) != '-' && temp >= Integer.MAX_VALUE) {
                return Integer.MAX_VALUE;
            }
        }
        return (int) (tag ? -temp : temp);
    }
}
